﻿using PlayerScannerCore.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace PlayerScanner
{
    public class CompactInventoryDataTemplateSelector : DataTemplateSelector
    {
        public DataTemplate WeaponTemplate { get; set; }
        public DataTemplate SWeaponTemplate { get; set; }
        public DataTemplate ArmorTemplate { get; set; }
        public DataTemplate ShieldTemplate { get; set; }
        public DataTemplate UnitTemplate { get; set; }
        public DataTemplate MagTemplate { get; set; }
        public DataTemplate TechDiskTemplate { get; set; }
        public DataTemplate RegularTemplate { get; set; }
        public DataTemplate DefaultTemplate { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            var itemViewModel = (ItemViewModel)item;
            if (itemViewModel != null)
            {
                switch (itemViewModel.ItemType)
                {
                case PlayerScannerCore.ItemType.SWeapon:
                    return SWeaponTemplate;
                case PlayerScannerCore.ItemType.Weapon:
                    return WeaponTemplate;
                case PlayerScannerCore.ItemType.Armor:
                    return ArmorTemplate;
                case PlayerScannerCore.ItemType.Shield:
                    return ShieldTemplate;
                case PlayerScannerCore.ItemType.Unit:
                    return UnitTemplate;
                case PlayerScannerCore.ItemType.Mag:
                    return MagTemplate;
                case PlayerScannerCore.ItemType.Meseta:
                case PlayerScannerCore.ItemType.Regular:
                    return RegularTemplate;
                case PlayerScannerCore.ItemType.TechDisk:
                    return TechDiskTemplate;
                default:
                    return DefaultTemplate;
                }
            }

            return DefaultTemplate;
        }
    }
}
